<template>
	<view class="code">
		<view class="head">
			<input type="text" v-model="verify_code" placeholder="请输入核验码" />
			<button @click="onSubmit">确定核验</button>
		</view>
		
		
		<view class="code-ma">
			<view class="yuans" @click="saoma">
				<image :src="baseUrl + '/static/wximages/staff_01.png'" mode="widthFix"></image>
				<text>扫码核验</text>
			</view>
		</view>
	</view>
</template>

<script>
	import { projectAudit } from '@/api/reserve.js';
	export default {
		data() {
			return {
				verify_code: '',
				baseUrl: this.$baseUrl
			}
		},
		methods: {
			saoma() {
				uni.scanCode({
					scanType: ['qrCode'],
					success: (res)=> {
						this.verify_code = res.result.split('=')[1];
						// uni.showModal({
						// 	content: JSON.stringify(res)
						// })
					}
				});
			},
			onSubmit() {
				if (!this.verify_code) {
					return this.$util.Tips({
						title: '请输入核验码'
					});
				}
				uni.showLoading({
					title: '核销中'
				});
				projectAudit({
					verify_code: this.verify_code
				}).then(res => {
					return this.$util.Tips({
						title: res.msg,
						icon: 'success'
					}, {
						tab: 2,
						url: ''
					});
				}).catch(err => {
					uni.hideLoading();
					return this.$util.Tips({
						title: err
					});
				})
			}
		}
	}
</script>
<style>
	page {
		background: #fff;
	}
</style>
<style scoped lang="scss">
	.head {
		margin-top: 110rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		input {
			width: 680rpx;
			height: 93rpx;
			background: #F8F8F8;
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			border: 1rpx solid #000000;
			padding: 10rpx;
		}
		button {
			width: 686rpx;
			height: 88rpx;
			background: #003153;
			border-radius: 8rpx 8rpx 8rpx 8rpx;
			margin-top: 44rpx;
			font-size: 32rpx;
			color: #FFFFFF;
			text-align: center;
			line-height: 88rpx;
		}
	}
	
	.code-ma {
		margin-top: 200rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		.yuans {
			width: 393rpx;
			height: 393rpx;
			background-color: #003153;
			border-radius: 50%;
			display: flex;
			align-items: center;
			justify-content: center;
			flex-direction: column;
			image {
				width: 160rpx;
				height: 160rpx;
			}
			text {
				font-size: 35rpx;
				color: #FFFFFF;
				margin-top: 33rpx;
			}
		}
	}
</style>